package com.hdax.dm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hdax.dm.dto.base.CarouselDto;
import com.hdax.dm.entity.base.Image;
import com.hdax.dm.mapper.base.ImageMapper;
import com.hdax.dm.service.ImageService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ImageServiceImpl extends ServiceImpl<ImageMapper, Image> implements ImageService {
    @Override
    public Image findImage(Long targetId,Long type,Long category) {
        //                  目标id          图片类型    图片分类
        QueryWrapper<Image> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("type",type);
        queryWrapper.eq("category",category);
        queryWrapper.eq("targetId",targetId);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public List<CarouselDto> carousel() {
        return baseMapper.carousel();
    }
}
